// index.js
import {
  Post,
  Get
} from "../../utils/request.js"
Page({
  data: {
    deviceName: "",
  },
  onLoad: function () {
   
  
  },
  onShow: function () {},
  /* 点击事件 */
  click: function (event) {
    var that = this;
    //调用扫码功能
    wx.scanCode({
      success: (res) => {
        console.log(res, "数据")
        console.log(res.result)
        
        //获取到二维码中的蓝牙设备名后跳转到连接页面
        var title = res.result;
        var index = title.indexOf("=");
        var tifjfgn = title.substr(index + 1, title.length);
        console.log(tifjfgn, "result")
        that.setData({
          deviceName: tifjfgn
        })
        wx.redirectTo({
          url: '../detail/index?id=' + tifjfgn
        })
      },
      fail: (res) => {
        wx.showToast({
          title: '扫码失败',
          icon: 'success',
          duration: 2000
        })
      },
    })
  },

  shufj: function () {
    // Post("/cabinetOpenRecord/openAllCabinetForInitialize", {
    //     cabinetId: 'C5:5C:1F:08:59:92'
    //   })
    //   .then(res => {
    //     console.log(res, "数据请求")
    //   })
  },
})